<?php

namespace app\common\model;
use think\Model;
use think\Request;

class Customer extends Model
{
    protected $noAuth = ['publiccus', 'get_cus', 'show',];
    protected $type = [
        'end_time' => 'timestamp',
        'jdata' => 'json'
    ];
    protected function base($query)
    {
        $query->where('shop_id', session('user_auth.shop_id'));
        //判断是否主账户
        $request= Request::instance();
        if(is_user_admin_account(session('user_auth.shop_id'), session('user_auth.user_id')) === FALSE and !in_array($request->action(), $this->noAuth)){
            $query->where('uid', session('user_auth.user_id'));
        }
        //不显示回收站
        if($request->controller() != 'Recovery'){
            $query->where('delete_time','0');
        }
    }
    protected function _initialize()
    {
        parent::_initialize();
        
    }
    //修改客户时间
    static function update_customers($id,$data){
        self::where(['id'=>$id])->update($data);
    }
    
}